package cn.quang.search.admin.mapper;

import cn.quang.search.admin.entity.po.EntityFieldDic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author:  Entity Generator
 * @since:  2024-02-27 19:03:42
 */
public interface EntityFieldDicMapper extends BaseMapper<EntityFieldDic> {

    default EntityFieldDic selectByDic(@Param("key") String dic) {
        return this.selectOne(new QueryWrapper<EntityFieldDic>().lambda().eq(EntityFieldDic::getDic, dic));
    }

    @Select(
            " SELECT entity_field_dic.* " +
            " FROM ( " +
            "    SELECT * FROM entity_logic_table_field_dic WHERE `dic` = #{logicTableFieldDicKey} AND `logic_table_id` = #{logicTableId} " +
            " ) logic_table_field_dic " +
            " INNER JOIN " +
            "    entity_field_dic " +
            " ON entity_field_dic.id = logic_table_field_dic.field_dic_id "
    )
    EntityFieldDic selectByLogicTableFieldDicKey(@Param("logicTableFieldDicKey") String logicTableFieldDicKey, @Param("logicTableId") long logicTableId);
}
